/**
 * 作者: hxl
 * 日期: 2024-12-15 22:50:03
 * 备注: 用户七天乐任务表
 */
package com.motu.monstercity.server.game.userdata;

import com.motu.monstercity.server.game.commondata.act.ActTask;
import com.motu.monstercity.server.game.logic.ActDaysManager;
import com.motu.vertx.module.utility.model.EntityManager;
import com.motu.vertx.module.utility.toolset.TimeUtils;
import com.motu.vertx.module.utility.toolset.Tool;

public class UserActDayTask extends UserActDayTaskModel {
    public UserActDayTask() {
        super();
    }
    public UserActDayTask(long userId, long actId, int taskType) {
        super();
        putUserId(userId);
        putActId(actId);
        putTaskType(taskType);
        putActListKey(EntityManager.getFieldJoinString(userId, actId));
    }

    public void reset() {
        int taskId = taskType;
        if (taskId > 1000000) {
            taskId = taskType / 1000000;
        }
        ActTask task = ActDaysManager.getActTaskByType(taskId);
        if (task == null) {
            return;
        }
        if (!TimeUtils.isToday(resetTime)) {
            if (task.getType() == ActTask.RESET_DAILY) {
                putCurP(0);
                putGetReward("");
            }
            putResetTime(TimeUtils.getCurTime());
            update();
        }
    }

}
